package com.jiayang.webview

import android.content.ContentResolver
import android.content.Context
import android.net.Uri
import android.os.Bundle
import android.util.Log
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import com.jiayang.common.autoservice.MyWebViewService
import com.jiayang.common.utils.MyServiceLoader

class MainActivity : AppCompatActivity() {

    val myWebViewService = MyServiceLoader.load(MyWebViewService::class.java)

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContentView(R.layout.activity_main)
        findViewById<Button>(R.id.start_demo).setOnClickListener{
            myWebViewService?.startWebViewActivity(this,"https://rockysports.cn/admin/zubiemanager","WebView",true)
//            val resolver =  getContentResolver()
//            val call =
//                resolver.call(Uri.parse("content://com.example.author"), "", null, null)
//            val string = call?.getString("All")
//            if (string != null) {
//                Log.i("MainActivity",string)
//            }

        }

    }

    /**
     * 获取应用程序名称
     */
    @Synchronized
    fun getAppName(context: Context): String? {
        try {
            val packageManager = context.packageManager
            val packageInfo = packageManager.getPackageInfo(
                context.packageName, 0
            )
            val labelRes = packageInfo.applicationInfo.labelRes
            return context.resources.getString(labelRes)
        } catch (e: Exception) {
            e.printStackTrace()
        }
        return null
    }
}